// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { game } from "../../../script/game/control/game";
import cardClass from "../../../script/game/model/cardModel";
import { mapClass } from "../../../script/game/model/mapModel";
import eventMgr from "../../../script/game/model/playerEvent";
import { playerClass } from "../../../script/game/model/playerModel";
import skillModel from "../../../script/game/model/skill";
import { timeClass } from "../../../script/game/model/timeModel";
import { gameService } from "../../../script/util/gameService";
import { ccs } from "../../../script/util/services";
import { WinBase } from "../../../script/wins/WinBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends WinBase{

    start () {
        this.touchEndEventScale(this.nodes.start, () => {
            if(game.gameMgr.saveState) {
                ccs.winMgr.showWin("popAlert", {
                    content: "确定重新开始游戏吗？ 开始之前请欣赏一段广告",
                    cb:() => {
                        ccs.AD.showVideoAd(() => {
                            game.gameMgr.clearGame();
                            game.gameMgr.initGame();
                            // 初始化游戏
                            ccs.winMgr.showWin("mainWin", {id: 1});
                            ccs.winMgr.showWin("loading");
                        })
                    }
                })
            } else {
                game.gameMgr.initGame();
                //         // 初始化游戏
                ccs.winMgr.showWin("mainWin", {id: 1});
                ccs.winMgr.showWin("loading");   
            }
            // ccs.winMgr.showWin("popAlert", {
            //     content: "确定开始游戏吗？ 这将会清空存档",
            //     cb:() => {
            //         game.gameMgr.clearGame();
            //         game.gameMgr.initGame();
            //         // 初始化游戏
            //         ccs.winMgr.showWin("mainWin", {id: 1});
            //         ccs.winMgr.showWin("loading");
            //     }
            // })
            
           
        })
        this.touchEndEventScale(this.nodes.continue, () => {
            //读取存档
            game.gameMgr.loadGame(() => {
                ccs.winMgr.showWin("mainWin");
            });
        })
    }
    

    // update (dt) {}
}
